/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chat;

/**
 *
 * @author dell
 */
public class perintah {

    public static void parsecommand(String command, boolean isModerator){
        if(command.charAt(0)=='/'){
            String[] commands = command.split(" ");
            for(int i = 0; i<commands.length; i++)
                System.out.println(commands[i]);

            if(commands[0].equals("/create")){
                //create room
                if(commands.length==2){
                    //bikin room commands[1] di kategori ini
                }
                else if(commands.length==3){
                    //bikin room commands[1] di kategori commands[2]
                }
                else
                    System.out.println("create: command error\n/create <roomname> [kategori]");
            }
            else if(commands[0].equals("/join")){
                //join room
                if(commands.length==2){
                    //masuk ke room commands[1]
                }
                else
                    System.out.println("join: command error\n/join <roomname>");
            }
            else if(commands[0].equals("/chat")){
                //do chat
                if(commands.length==2){
                    //chat dengan user commands[1]
                }
                else
                    System.out.println("chat: command error\n/chat <username>");
            }
            else if(commands[0].equals("/addfriend")){
                //add friend
                if(commands.length==2){
                    //menambah user commands[1] sebagai friend
                }
                else
                    System.out.println("addfriend: command error\n/addfriend <username>");

            }
            else if(commands[0].equals("/exit")){
                //exit room / chat
            }
            else if(commands[0].equals("/info")){
                //get information
                if(commands.length==2){
                    //menampilkan informasi user/room commands[1]
                }
                else
                    System.out.println("info: command error\n/info [roomname|username]");
            }
            
            //khusus moderator / owner
            else if(commands[0].equals("/kick")){
                //kick user
                if(isModerator){
                    if(commands.length==2){
                        //mengeluarkan user commands[1]
                    }
                    else
                        System.out.println("kick: command error\n/kick <username>");
                }
                else
                    System.out.println("you don't have permission to do this");
            }
            else if(commands[0].equals("/ban")){
                //ban user
                if(isModerator){
                    if(commands.length==2){
                        //ban user commands[1]
                    }
                    else
                        System.out.println("ban: command error\n/ban <username>");
                }
                else
                    System.out.println("you don't have permission to do this");
            }
            else if(commands[0].equals("/unban")){
                //unban user
                if(isModerator){
                    if(commands.length==2){
                        //membatalakn ban user commands[1]
                    }
                    else
                        System.out.println("unban: command error\n/unban <username>");

                }
                else
                    System.out.println("you don't have permission to do this");
            }
            else if(commands[0].equals("/persist")){
                //set persistence
                if(isModerator){
                    if(commands.length==2){
                        if(commands[1].equals("on")){
                            //set persist on
                        }
                        else if(commands[1].equals("off")){
                            //set persist off
                        }
                        else
                            System.out.println("persist: command error\n/persist <on|off>");
                    }
                    else
                        System.out.println("persist: command error\n/persist <on|off>");
                }
                else
                    System.out.println("you don't have permission to do this");
            }
            else if(commands[0].equals("/setowner")){
                //set owner
                if(isModerator){
                    if(commands.length==2){
                        //mengeset user commands[1] sebagai owner
                    }
                    else
                        System.out.println("setowner: command error\n/setowner <username>");
                }
                else
                    System.out.println("you don't have permission to do this");
            }
            else
                System.out.println("command undefined");
        }
        else
            System.out.println("that's not a command");
    }

    public static void main(String[] args){
        String command="/create room kategori";
        parsecommand(command,false);
    }
}
